//
// Created by tianq on 25-5-3.
// The shape application. Initially we need only squares and circles. Provide this solution.
//

#include <iostream>
#include <memory>
#include <vector>
using namespace std;

class Shape {
public:
    virtual void draw() = 0;

    virtual ~Shape() = default;
};

class Circle final : public Shape {
    float radius{};

public:
    explicit Circle(const float radius = 1.0f) {
        cout << "Circle::Circle(radius=" << radius << ")" << endl;
        this->radius = radius;
    }

    void draw() override {
        cout << "Circle::draw(), area=" << radius * radius * 3.14f << endl;
    }
};

class Square final : public Shape {
    float side{};

public:
    explicit Square(const float side = 1.0f) {
        cout << "Square::Square(side=" << side << ")" << endl;
        this->side = side;
    }

    void draw() override {
        cout << "Square::draw(), area=" << side * side << endl;
    }
};

int main() {
    vector<unique_ptr<Shape>> shapes;

    shapes.push_back(make_unique<Circle>(5.0f));
    shapes.push_back(make_unique<Square>(3.0f));

    for (const auto& shape : shapes) shape->draw();
}
